import { Router } from 'express';
import {
  getOrders,
  getOrderById,
  getOrderByNo,
  createOrder,
  updateOrder,
  deleteOrder,
  getOrderStats,
  payOrder,
  shipOrder,
  confirmOrder,
  cancelOrder
} from '../controllers/orderController';
import { authenticate } from '../middleware/auth';

const router = Router();

// 获取订单统计
router.get('/stats', authenticate, getOrderStats);

// 获取订单列表
router.get('/', authenticate, getOrders);

// 根据订单号获取订单详情
router.get('/order-no/:orderNo', authenticate, getOrderByNo);

// 根据ID获取订单详情
router.get('/:id', authenticate, getOrderById);

// 创建订单
router.post('/', authenticate, createOrder);

// 更新订单
router.put('/:id', authenticate, updateOrder);

// 删除订单
router.delete('/:id', authenticate, deleteOrder);

// 支付订单
router.post('/:id/pay', authenticate, payOrder);

// 发货
router.post('/:id/ship', authenticate, shipOrder);

// 确认收货
router.post('/:id/confirm', authenticate, confirmOrder);

// 取消订单
router.post('/:id/cancel', authenticate, cancelOrder);

export default router;